#include #include #include using namespace std; void main() { string filename; string input; string longest; string shortest; cout << "FileName? "; getline(cin,filename); //fin is just a variable name, it is called a file handle ifstream fin; fin.open(filename.c_str()); while(fin.fail()) { //fin.clear(); cout << filename << " not found" << endl; cout << "FileName? "; getline(cin,filename); fin.open(filename.c_str()); } //cout << "Name> "; getline(fin,input); longest = input; shortest = input; do { //cout << "Name> "; getline(fin,input); if(input != "Quit" && input != "") { if(input.length() > longest.length()) { longest = input; } if(input.length() < shortest.length()) { shortest = input; } } } while(!fin.eof()); cout << "Longest name = " << longest << endl; cout << "Shortest name = " << shortest << endl; fin.close(); }